﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PacCraft
{
    class Text
    {
        private SpriteFont font;
        public Color color = Color.White;
        public Vector2 position = new Vector2(150, 250);
        public string text;
        private Random r;
        private float alpha = 1f;
        public bool fade = false;
        public int timer = 100;

        public Text(SpriteFont _font, string _text, bool fadeOut = false)
        {
            font = _font;
            text = _text;
            r = new Random();
            fade = fadeOut;
        }

        public void reset(string _text, bool fadeOut = false)
        {
            text = _text;
            alpha = 1f;
            fade = fadeOut;
        }

        public void Draw(SpriteBatch spriteBatch, bool randomColor = false)
        {
            if (randomColor)
                color = new Color(new Vector3((float)r.NextDouble(), (float)r.NextDouble(), (float)r.NextDouble()));
            if (fade)
                alpha -= 1f / 100;
            spriteBatch.DrawString(font, text, position, color * alpha);
        }
    }
}
